package com.aopcinemas.visitor.behaviour;

import jade.content.Predicate;
import jade.content.lang.Codec.CodecException;
import jade.content.onto.OntologyException;
import jade.content.onto.basic.TrueProposition;
import jade.core.Agent;
import jade.lang.acl.ACLMessage;
import jade.proto.AchieveREInitiator;

import com.aopcinemas.visitor.VisitorAgent;

public class CampaignRequestInitiator extends AchieveREInitiator {

    private static final long serialVersionUID = 1L;

    public CampaignRequestInitiator(Agent a, ACLMessage msg) {
        super(a, msg);
    }

    @Override
    protected void handleInform(ACLMessage inform) {
        try {
            VisitorAgent agent = (VisitorAgent) myAgent;
            Predicate predicate = (Predicate) myAgent.getContentManager().extractContent(inform);
            if (predicate instanceof TrueProposition) {
                agent.notifyMessage("Hei, your invitation offer was accepted!");
            } else {
                agent.notifyMessage("Hei, your invitation offer was rejected!");
            }
        } catch (CodecException e) {
            e.printStackTrace();
        } catch (OntologyException e) {
            e.printStackTrace();
        }

    }
}
